package com.ybkj.daijia.server.service.impl;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.ybkj.daijia.serverUtils.SettingUtils;
import com.ybkj.daijia.chart.TableOrderMonthVo;
import com.ybkj.daijia.common.CompanyOrderVo;
import com.ybkj.daijia.common.DriverOrderDetailVo;
import com.ybkj.daijia.common.DriverOrderVo;
import com.ybkj.daijia.common.MemberOrderVo;
import com.ybkj.daijia.common.OrderFromSourceVo;
import com.ybkj.daijia.common.PageVo;
import com.ybkj.daijia.common.Result;
import com.ybkj.daijia.config.ErrandUpApi;
import com.ybkj.daijia.config.PassengerApi;
import com.ybkj.daijia.config.SalesApi;
import com.ybkj.daijia.page.Page;
import com.ybkj.daijia.page.Pageable;
import com.ybkj.daijia.page.domain.Sort;
import com.ybkj.daijia.server.errand.ErrandAcKey;
import com.ybkj.daijia.server.errand.ErrandOrderTypeOtherServices;
import com.ybkj.daijia.server.errand.ErrandOrderTypeTips;
import com.ybkj.daijia.server.errand.ErrandPay;
import com.ybkj.daijia.server.errand.ErrandTypeCompany;
import com.ybkj.daijia.server.errand.OrderOrbit;
import com.ybkj.daijia.server.errand.OrderRefuse;
import com.ybkj.daijia.server.errand.OrderTemp;
import com.ybkj.daijia.server.errand.OrderType;
import com.ybkj.daijia.server.errand.OrderUp;
import com.ybkj.daijia.server.errand.OrderUp.PayTypeDetails;
import com.ybkj.daijia.server.errand.PayRecordOrder;
import com.ybkj.daijia.server.mapper.AreaMapper;
import com.ybkj.daijia.server.mapper.CompanyMapper;
import com.ybkj.daijia.server.mapper.DriverChoseLevelPaotuiMapper;
import com.ybkj.daijia.server.mapper.DriverLevelDetailMapper;
import com.ybkj.daijia.server.mapper.DriverLevelMapper;
import com.ybkj.daijia.server.mapper.DriverLevelMoneyTimeDetailMapper;
import com.ybkj.daijia.server.mapper.DriverMapper;
import com.ybkj.daijia.server.mapper.DriverPaymentsRecordMapper;
import com.ybkj.daijia.server.mapper.FinancialRecordMapper;
import com.ybkj.daijia.server.mapper.FirstOrderPassengerMapper;
import com.ybkj.daijia.server.mc.Passenger;
import com.ybkj.daijia.server.mc.PassengerAddress;
import com.ybkj.daijia.server.mc.PassengerConcats;
import com.ybkj.daijia.server.model.Area;
import com.ybkj.daijia.server.model.ChartDay;
import com.ybkj.daijia.server.model.ChartMonth;
import com.ybkj.daijia.server.model.ChartYear;
import com.ybkj.daijia.server.model.Driver;
import com.ybkj.daijia.server.model.Rate;
import com.ybkj.daijia.server.sales.Coupon;
import com.ybkj.daijia.server.service.AreaService;
import com.ybkj.daijia.server.service.ErrandUpService;
import com.ybkj.daijia.server.service.MemberService;
import com.ybkj.daijia.server.service.SmsService;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.ApplicationEventMulticaster;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class DefaultErrandUpService implements ErrandUpService {

    @Autowired
    private DriverMapper driverMapper;
    @Autowired
    private MemberService memberService;
    @Autowired
    private DriverChoseLevelPaotuiMapper driverChoseLevelPaotuiMapper;

    @Autowired
    private DriverLevelMapper driverLevelMapper;

    @Autowired
    private DriverLevelDetailMapper driverLevelDetailMapper;

    @Autowired
    private DriverLevelMoneyTimeDetailMapper driverLevelMoneyTimeDetailMapper;

    @Autowired
    private CompanyMapper companyMapper;

    @Autowired
    private FinancialRecordMapper financialRecordMapper;

    @Autowired
    private DriverPaymentsRecordMapper driverPaymentsRecordMapper;

    @Autowired
    private FirstOrderPassengerMapper firstOrderPassengerMapper;

    @Autowired
    private SettingUtils settingUtils;

    @Autowired
    private ErrandUpApi errandApi;

    @Autowired
    private PassengerApi passengerApi;

    @Autowired
    private ApplicationEventMulticaster applicationEventMulticaster;

    @Autowired
    private AreaMapper areaMapper;

    @Autowired
    private AreaService areaService;

    @Autowired
    private SmsService smsService;

    @Autowired
    private SalesApi salesApi;

    public static void main(String[] args)
        throws JsonParseException, JsonMappingException, IOException {
//    	String string16 = "{'treatment':false,'orderLat':null,'treatmentDate':null,'startTime':'2017-06-03 10:10:56','fixedPrice':null,'created':'2017-06-03 10:10:56','deliverLat':null,'mileage':0,'channelId':null,'couponMoney':null,'otherMoney':null,'companyName':'成都分公司','signMoney':null,'driverProfit':null,'content':'亲戚','addServices':'','payTypeDetails':'cash','passengerName':'刘晨临','errandFixPrice':null,'review':false,'unionpayMoney':null,'passengerId':169,'deliverAddress':'','version':1,'title':null,'buyNeeds':'我问','errandValuationMethod':null,'otherServices':null,'startPhone':null,'cancelCause':null,'channelName':'APP预约','justKilometres':null,'recipients':'15283753017','startLng':103.8197937011719,'orderLng':null,'employPhone':null,'lasturge':'2017-06-03 10:10:56','employId':null,'guoluMoney':null,'employMemo':null,'ifPayed':false,'cashMoney':null,'driverCompanyId':null,'travelTime':0,'phone':'','round':1,'startDetailed':'','shouldPay':39,'travelTimePrice':0,'updated':'2017-06-03 10:10:56','orderTypeId':41,'realPay':0,'finishTime':null,'deliverTime':null,'alipayMoney':null,'waitPrice':null,'passengerPhone':'15283753017','status':0,'orderType':'修电脑','goodsCash':0,'orderAddress':null,'couponId':null,'mileagePrice':0,'baoxiao':null,'waitedTime':null,'isclosed':false,'justMoney':null,'baoxiaoMoney':0,'weight':'','voice':null,'imglist':null,'appkey':'cb904bd8a16d4511bbd826d68e554098','endDetailed':'','areaId':56,'id':403,'orderReview':null,'anonymousNumber':null,'errandserviceType':null,'employName':'','memoList':[],'startAddress':'成都SBI创业街','imgs':'','thanksCash':0,'matter':null,'statusList':null,'tipsList':null,'prePayTypeDetail':null,'startPrice':39,'platNo':null,'yuanchengMoney':null,'balanceMoney':null,'orderNo':'PT1706030077','endPhone':null,'startLat':30.67519760131836,'companyId':54,'weixinMoney':null,'tips':'','companyProfit':null,'errandOrderTypeDetaileds':[{'id':487,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'叫修需求','seq':1,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':1,'pid':41,'prompt':'请描述维修需求','isShow':1},{'id':488,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'预约时间','seq':2,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':0,'pid':41,'prompt':'请输入时间','isShow':0},{'id':489,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'叫修起点地址','seq':3,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':1,'pid':41,'prompt':'起点','isShow':1},{'id':490,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'详细起点','seq':4,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':0,'pid':41,'prompt':'详细起点','isShow':0},{'id':491,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'叫修终点地址','seq':5,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':1,'pid':41,'prompt':'终点','isShow':1},{'id':492,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'详细终点','seq':6,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':0,'pid':41,'prompt':'详细终点','isShow':0},{'id':493,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'电话','seq':7,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':1,'pid':41,'prompt':'电话','isShow':1},{'id':494,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'电话','seq':8,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':0,'pid':41,'prompt':'电话','isShow':0},{'id':495,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'重量','seq':9,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':0,'pid':41,'prompt':'重量','isShow':0},{'id':496,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'商品金额','seq':10,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':0,'pid':41,'prompt':'商品金额','isShow':0},{'id':497,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'感谢费','seq':11,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':1,'pid':41,'prompt':'感谢费','isShow':1},{'id':498,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'上传图片','seq':12,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':0,'pid':41,'prompt':'上传图片','isShow':0},{'id':499,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'叫修品种','seq':13,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':0,'pid':41,'prompt':'请输入叫修品种','isShow':0},{'id':500,'updated':'2017-10-13 13:48:38','created':'2017-05-27 15:42:29','name':'附近服务','seq':14,'appkey':'cb904bd8a16d4511bbd826d68e554098','isRequire':0,'pid':41,'prompt':'附近服务','isShow':0}],'deliverLng':null}";
//    	String string16 = "{'justMoney':null,'baoxiaoMoney':0,'weight':'','voice':null,'imglist':null,'appkey':'cb904bd8a16d4511bbd826d68e554098','endDetailed':'','areaId':56,'id':403,'orderReview':null,'anonymousNumber':null,'errandserviceType':null,'employName':'','memoList':[],'startAddress':'成都SBI创业街','imgs':'','thanksCash':0,'matter':null,'statusList':null,'tipsList':null,'prePayTypeDetail':null}";
//    	JSONObject object16 = new JSONObject(string16);
//    	if (object16.getString("weight").isEmpty()) {
//    		object16.put("weight", Double.parseDouble("0"));
//    	} else {
//    		object16.put("weight", Double.parseDouble(object16.getString("weight")));
//    	}
//    	Gson gson=new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
//    	OrderUp orderUp16 = gson.fromJson(object16.toString(),new TypeToken<OrderUp>() {}.getType());

    }

    /**
     * 查询拒单记录
     */
    @Override
    public Page<OrderRefuse> queryRefuses(Long companyId, Date start, Date end, String param) {
        Page<OrderRefuse> page = new Page<OrderRefuse>() {
            @Override
            public int getTotalPages() {
                return 0;
            }

            @Override
            public long getTotalElements() {
                return 0;
            }

            @Override
            public int getNumber() {
                return 0;
            }

            @Override
            public int getSize() {
                return 0;
            }

            @Override
            public int getNumberOfElements() {
                return 0;
            }

            @Override
            public List<OrderRefuse> getContent() {
                return null;
            }

            @Override
            public boolean hasContent() {
                return false;
            }

            @Override
            public Sort getSort() {
                return null;
            }

            @Override
            public boolean isFirst() {
                return false;
            }

            @Override
            public boolean isLast() {
                return false;
            }

            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public boolean hasPrevious() {
                return false;
            }

            @Override
            public Pageable nextPageable() {
                return null;
            }

            @Override
            public Pageable previousPageable() {
                return null;
            }

            @Override
            public Iterator<OrderRefuse> iterator() {
                return null;
            }
        };
        return page;
    }

    /**
     * 查询跑腿订单记录
     */
    @Override
    public Page<OrderUp> queryErrandOrder(Long companyId, Date start, Date end, String orderType,
        String param, String status, String orderby) {
        Page<OrderUp> page = new Page<OrderUp>() {
            @Override
            public int getTotalPages() {
                return 0;
            }

            @Override
            public long getTotalElements() {
                return 0;
            }

            @Override
            public int getNumber() {
                return 0;
            }

            @Override
            public int getSize() {
                return 0;
            }

            @Override
            public int getNumberOfElements() {
                return 0;
            }

            @Override
            public List<OrderUp> getContent() {
                return null;
            }

            @Override
            public boolean hasContent() {
                return false;
            }

            @Override
            public Sort getSort() {
                return null;
            }

            @Override
            public boolean isFirst() {
                return false;
            }

            @Override
            public boolean isLast() {
                return false;
            }

            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public boolean hasPrevious() {
                return false;
            }

            @Override
            public Pageable nextPageable() {
                return null;
            }

            @Override
            public Pageable previousPageable() {
                return null;
            }

            @Override
            public Iterator<OrderUp> iterator() {
                return null;
            }
        };
        return page;
    }

    /**
     * 保存跑腿订单
     *
     * @throws Exception
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result<OrderUp> save(OrderUp order) {

        Result<OrderUp> r = new Result<OrderUp>();

        return r;
    }

    /**
     * 保存跑腿临时订单
     *
     * @throws Exception
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result<OrderTemp> saveTemp(OrderTemp orderTemp) {
        Result<OrderTemp> r = new Result<OrderTemp>();

        return r;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result<OrderUp> cancelOrder(OrderUp order, String cancelCause) {
        Result<OrderUp> result = new Result<OrderUp>();
        return result;

    }

    @Override
    public OrderUp findOne(Long id) {
        OrderUp orderUp = new OrderUp();
        return orderUp;
    }

    @Override
    public OrderTemp findOneTemp(Long id) {
//      OrderTemp orderTemp=null;
//      StringBuilder sb=new StringBuilder();
//      sb.append(errandApi.getErrandBaseURL()).append(ErrandUpApi.QUERY_ONE_TEMP).append("?appKey={appKey}");
//      sb.append("&id={id}");
//      Map<String,String> kv = new HashMap<String,String>();
//
//      kv.put("id",String.valueOf(id));
//
//      String result = errandApi.get(sb.toString(), kv, settingUtils.get());
//      if(null!=result){
//          JSONObject jo=new JSONObject(result);
//          Integer code = jo.getInt("code");
//          if(code==0){
//              JSONObject data=jo.getJSONObject("data");
//              Gson gson=new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
//              orderTemp = gson.fromJson(data.toString(),OrderTemp.class);
//          }
//      }
        OrderTemp orderTemp = new OrderTemp();
        return orderTemp;
    }

    @Override
    public void remark(Long id, String memo) {

    }

    //评价订单
    @Override
    public void review(Long id, String content, Double score) {

    }

    @Transactional(rollbackFor = Exception.class)
    public Result<OrderUp> paidan(Driver driver, OrderUp order) {

        Result<OrderUp> result = new Result<>();
        return result;
    }

    @Override
    public Long countBusyAmount(Long id) {

        return 0L;
    }

    @Override
    public List<ErrandAcKey> feelist() {

        List<ErrandAcKey> list = new LinkedList<>();
        return list;
    }

    @Override
    public Result<ErrandAcKey> addNewfee(String name, String acKey) {

        Result<ErrandAcKey> result = new Result<ErrandAcKey>();

        return result;

    }

    @Override
    public Result<ErrandPay> addNewfeeContent(String city, String content, Long acKeyId) {

//
        Result<ErrandPay> result = new Result<ErrandPay>();
        return result;

    }

    @Override
    public ErrandPay findOneErrandPay(Long id) {

        ErrandPay errandPay = new ErrandPay();
        return errandPay;

    }

    @Override
    public Result<ErrandPay> updateFeecontent(Long id, String city, String content) {

//        }
        Result<ErrandPay> result = new Result<ErrandPay>();

        return result;

    }

    @Override
    public Result<ErrandAcKey> deleteFee(Long id) {

        Result<ErrandAcKey> result = new Result<ErrandAcKey>();
//        }

        return result;

    }

    @Override
    public Result<ErrandPay> deleteFeeContent(Long id) {

        Result<ErrandPay> result = new Result<ErrandPay>();

        return result;

    }

    @Override
    public List<PassengerConcats> findPassengerConcats(Long passengerId) {
        List<PassengerConcats> list = new LinkedList<>();
        return list;
    }

    @Override
    public PassengerAddress findPassengerToPlace(Long passengerId, Integer type) {
        PassengerAddress passengerAddress = new PassengerAddress();
        return passengerAddress;
    }

    //收回订单
    @Override
    public Result<OrderUp> callback(Long id, String cause) {
        Result<OrderUp> result = new Result<OrderUp>();
        return result;
    }

    @Override
    public List<OrderUp> selectCuidan() {

        List<OrderUp> list = new ArrayList<OrderUp>();
        return list;
    }

    @Override
    public void closeCuidan(Long orderId) {

    }

    @Transactional(rollbackFor = Exception.class)
    public Result<OrderUp> completeTask(OrderUp order) {

        Result<OrderUp> result = new Result<>();
        return result;
    }

    @Override
    public ChartYear dataForYear(Integer year, Long companyId) {

        ChartYear chartYear = new ChartYear();
        return chartYear;
    }

    @Override
    public ChartMonth errandDataForMonth(Integer year, Integer month,
        Long companyId) {

        ChartMonth chartMonth = new ChartMonth();
        return chartMonth;
    }

    @Override
    public List<TableOrderMonthVo> tableOrderMonth(Integer year, Long companyId) {
        List<TableOrderMonthVo> lists = new LinkedList<>();
        return lists;
    }

    @Override
    public ChartDay errandDataForDay(Integer year, Integer month, Integer day,
        Long companyId) {

        ChartDay chartDay = new ChartDay();
        return chartDay;
    }

    @Override
    public List<OrderUp> findMonthOrder(Integer year, Integer month) {
        List<OrderUp> list = new LinkedList<>();
        return list;
    }

    @Override
    public PageVo<OrderFromSourceVo> orderFromSource(Date start, Date end,
        Long companyId) {

        PageVo<OrderFromSourceVo> orderFromSourceVos = new PageVo<>();
        return orderFromSourceVos;
    }

    @Override
    public PageVo<CompanyOrderVo> companyOrder(Date start, Date end) {

        PageVo<CompanyOrderVo> companyOrderVos = new PageVo<>();
        return companyOrderVos;
    }

    @Override
    public PageVo<DriverOrderVo> errandIntroduce(Long companyId, Date start, Date end) {
        PageVo<DriverOrderVo> list = new PageVo<>();
        return list;

    }

    @Override
    public PageVo<MemberOrderVo> errandMemberOrder(Date startTime, Date endTime, Long companyId,
        Long gradeId, Integer type) {

        PageVo<MemberOrderVo> vopage = new PageVo<>();
        return vopage;
    }

    @Override
    public Map<String, Object> getPrice(Area area, Double distance, Integer time) {
//        Map<String, Object> map = new HashMap<String, Object>();
//        if (area != null) {
//            Integer travelTime = 0;
//            Double mileage = 0.0;
//            if (time != null) {
//                travelTime = (int) (time / 60);
//            }
//            if (distance != null) {
//                mileage = Double.valueOf(distance / 1000);
//            }
//            BigDecimal money = BigDecimal.ZERO;
//
//            SelectPrice selectPrice = new SelectPrice();
//            selectPrice.setPrice(travelTime, mileage, area, null, 0D);
//
//            money = selectPrice.shouldCash;
//            BigDecimal startPrice = selectPrice.qbCost;
//            BigDecimal mileagePrice = selectPrice.disCost;
//            BigDecimal travelTimePrice = selectPrice.travalTimeCost;
//
//            ChargeStartTime price = selectPrice.getPrice();
//            StringBuilder builder = new StringBuilder();
//            builder.append("起步价:" + startPrice + "元\n");
//            List<ChargeStartDistance> distances = price.getChargeStartDistances();
//
//            if (distances != null && distances.size() != 0) {
//                for (ChargeStartDistance d : distances) {
//                    builder.append(d.getStartdistance() + "公里到" + d.getDistance() + "公里内,加收" + d.getMoney() + "元");
//                    builder.append("\n");
//                }
//            }
//
//            builder.append("超过" + price.getQblc() + "公里");
//            builder.append("以后每" + price.getDjglUnit() + "公里");
//            builder.append("加收" + price.getDjglCost() + "元");
//            if (price.getDjglThresholdt() != 0) {
//                builder.append("(不足" + price.getDjglThresholdt() + "公里不计费)");
//            }
//            builder.append("\n");
//            builder.append("起步后" + price.getQbsj() + "分钟内不收费");
//            builder.append("以后每" + price.getDjsjUnit() + "分钟");
//            builder.append("加收" + price.getDjsjCost() + "元");
//            if (price.getDjsjThresholdt() != 0) {
//                builder.append("(不足" + price.getDjsjThresholdt() + "分钟不收费)");
//            }
//            builder.append("\n");
//            builder.append("免费等候" + price.getMfdhsj() + "分钟");
//            BigDecimal bigDecimal = price.getDhsjAtonceCost();
//
//            if (bigDecimal.compareTo(BigDecimal.ZERO) == 1) {
//                builder.append("到达则立即加收" + price.getDhsjAtonceCost() + "元");
//            }
//            builder.append("后每" + price.getDhsjUnit() + "分钟");
//            builder.append("加收" + price.getDhsjCost() + "元");
//            if (price.getDhsjThresholdt() != 0) {
//                builder.append("(低于" + price.getDhsjThresholdt() + "分钟不计费)");
//            }
//            builder.append("\n");
//            if (StringUtils.isNotBlank(area.getMemo())) {
//                builder.append("备注:" + area.getMemo());
//            }
//            String pay_detail = builder.toString();
//
//            map.put("success", true);
//            map.put("message", "请求成功");
//            map.put("money", money != null ? money.doubleValue() : 0);
//            map.put("travelTime", travelTime);                //执行时间    分钟
//            map.put("time", travelTime);                //执行时间    分钟
//            map.put("startPrice", startPrice != null ? startPrice.doubleValue() : 0);            //起步价
//            map.put("mileage", mileage);                //行驶里程      公里
//            map.put("mileagePrice", mileagePrice != null ? mileagePrice.doubleValue() : 0);        //行驶里程费用
//            map.put("travelTimePrice", travelTimePrice != null ? travelTimePrice.doubleValue() : 0); //服务时间费用
//            map.put("pay_detail", pay_detail);
//        } else {
//            map.put("success", false);
//            map.put("message", "收费标准为空");
//        }
        Map<String, Object> map = new HashMap<String, Object>();
        return map;
    }

    @Override
    public Page<Map<String, Object>> orderListData(
        String orderNo, String passengerPhone, String employPhone, Long companyId,
        String companyName,
        String startTime, String endTime, String allorderType, String allErrandOrderType,
        String allstatus,
        Integer page, Integer rows, String treatment, String startFinishTime, String endFinishTime)
        throws ParseException {
        Page<Map<String, Object>> mapPage = new Page<Map<String, Object>>() {
            @Override
            public int getTotalPages() {
                return 0;
            }

            @Override
            public long getTotalElements() {
                return 0;
            }

            @Override
            public int getNumber() {
                return 0;
            }

            @Override
            public int getSize() {
                return 0;
            }

            @Override
            public int getNumberOfElements() {
                return 0;
            }

            @Override
            public List<Map<String, Object>> getContent() {
                return null;
            }

            @Override
            public boolean hasContent() {
                return false;
            }

            @Override
            public Sort getSort() {
                return null;
            }

            @Override
            public boolean isFirst() {
                return false;
            }

            @Override
            public boolean isLast() {
                return false;
            }

            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public boolean hasPrevious() {
                return false;
            }

            @Override
            public Pageable nextPageable() {
                return null;
            }

            @Override
            public Pageable previousPageable() {
                return null;
            }

            @Override
            public Iterator<Map<String, Object>> iterator() {
                return null;
            }
        };
        return mapPage;
    }

    @Override
    public List<Map<String, Object>> orderListDataExport(
        String orderNo, String passengerPhone, String employPhone, Long companyId,
        String companyName,
        String startTime, String endTime, String allorderType, String allErrandOrderType,
        String allstatus,
        String treatment, String startFinishTime, String endFinishTime) throws ParseException {

        List<Map<String, Object>> content = new LinkedList<>();
        return content;
    }

    public PageVo<DriverOrderDetailVo> driverOrderDetail(Long driverId, Date start, Date end) {
//        Pageable pageable = new PageRequest(Pager.getPage(), Pager.getLimit());
//        StringBuilder builder = new StringBuilder();
//        builder.append(errandApi.getErrandBaseURL()).append(ErrandUpApi.DRIVERORDERDETAILVO).append(".json?appKey={appKey}&page={page}&rows={rows}");
//        Map<String, String> kv = new HashMap<String, String>();
//        kv.put("page", String.valueOf(Pager.getPage() + 1));
//        kv.put("rows", String.valueOf(Pager.getLimit()));
//        if (driverId != null) {
//            kv.put("driverId", driverId + "");
//            builder.append("&driverId={driverId}");
//        }
//        if (start != null) {
//            kv.put("startDate", start.getTime() + "");
//            builder.append("&startDate={startDate}");
//        }
//        if (end != null) {
//            kv.put("endDate", end.getTime() + "");
//            builder.append("&endDate={endDate}");
//        }
//        String result = errandApi.get(builder.toString(), kv, settingUtils.get());
//        PageVo<DriverOrderDetailVo> page = new PageVo<DriverOrderDetailVo>();
//        if (null != result) {
//            JSONObject jo = new JSONObject(result);
//            Integer code = jo.getInt("code");
//            if (code == 0) {
//                JSONObject data = jo.getJSONObject("data");
//                Gson gson = new GsonBuilder().setDateFormat(com.ybkj.daijia.constant.DateConstant.DATE_TIME_FORMATE).create();
//                page = gson.fromJson(data.toString(), new TypeToken<PageVo<DriverOrderDetailVo>>() {
//                }.getType());
//            }
//        }
        PageVo<DriverOrderDetailVo> page = new PageVo<>();
        return page;
    }

    /**
     * 查询订单类型
     */
    @Override
    public List<OrderType> queryOrderType(Long companyId) {
//        List<OrderType> list = new ArrayList<OrderType>();
//        StringBuilder builder = new StringBuilder();
//        builder.append(errandApi.getErrandBaseURL()).append(ErrandUpApi.QUERY_ORDER_TYPE).append("?appKey={appKey}");
//        Map<String, String> kv = new HashMap<String, String>();
//        kv.put("companyId", String.valueOf(companyId));
//        builder.append("&companyId={companyId}");
//        String result = errandApi.get(builder.toString(), kv, settingUtils.get());
//        if (null != result) {
//            JSONObject jo = new JSONObject(result);
//            Integer code = jo.getInt("code");
//            if (code == 0) {
//                JSONArray data = jo.getJSONArray("data");
//                Gson gson = new GsonBuilder().setDateFormat(com.ybkj.daijia.constant.DateConstant.DATE_TIME_FORMATE).create();
//                list = gson.fromJson(data.toString(), new TypeToken<List<OrderType>>() {
//                }.getType());
//                if (list != null && list.size() != 0) {
//                    for (OrderType orderType : list) {
//                        Long areaId = orderType.getAreaId();
//                        if (areaId != null) {
//                            Area area = areaService.findOne(areaId);
//                            if (area != null) {
//                                orderType.setAreaName(area.getName());
//                            }
//                        }
//                    }
//                }
//            }
//        }
        List<OrderType> list = new ArrayList<OrderType>();
        return list;
    }

    @Override
    public Page<Map<String, Object>> queryOrderTypeByParams(String typeName) {
//        Pageable pageable = new PageRequest(Pager.getPage(), Pager.getLimit());
//        StringBuilder builder = new StringBuilder();
//        builder.append(errandApi.getErrandBaseURL()).append(ErrandUpApi.QUERY_ORDERTYPE_BY_TYPENAME).append("?appKey={appKey}&page={page}&rows={rows}");
//        Map<String, String> kv = new HashMap<String, String>();
//        if (StringUtils.isNotBlank(typeName)) {
//            kv.put("typeName", typeName);
//            builder.append("&typeName={typeName}");
//        }
//        kv.put("page", String.valueOf(Pager.getPage() + 1));
//        kv.put("rows", String.valueOf(Pager.getLimit()));
//        String result = errandApi.get(builder.toString(), kv, settingUtils.get());
//
//        List<OrderType> list = new ArrayList<OrderType>();
//        List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
//        Long total = 0L;
//        if (null != result) {
//            JSONObject jo = new JSONObject(result);
//            Integer code = jo.getInt("code");
//            if (code == 0) {
//                JSONObject data = jo.getJSONObject("data");
//                total = data.getLong("total");
//                Gson gson = new GsonBuilder().setDateFormat(com.ybkj.daijia.constant.DateConstant.DATE_TIME_FORMATE).create();
//                list = gson.fromJson(data.getJSONArray("rows").toString(), new TypeToken<List<OrderType>>() {
//                }.getType());
//                if (list != null && list.size() != 0) {
//                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
//                    for (OrderType orderType : list) {
//                        Map<String, Object> map = new HashMap<String, Object>();
//                        map.put("id", orderType.getId());
//                        map.put("typeName", orderType.getTypeName());
//                        map.put("typeSeq", orderType.getTypeSeq());
//                        map.put("companyName", orderType.getCompanyName());
//                        map.put("created", format.format(orderType.getCreated()));
//                        listMap.add(map);
//                    }
//                }
//            }
//        }
//        return new PageImpl<Map<String, Object>>(listMap, pageable, total);
        Page<Map<String, Object>> mapPage = new Page<Map<String, Object>>() {
            @Override
            public int getTotalPages() {
                return 0;
            }

            @Override
            public long getTotalElements() {
                return 0;
            }

            @Override
            public int getNumber() {
                return 0;
            }

            @Override
            public int getSize() {
                return 0;
            }

            @Override
            public int getNumberOfElements() {
                return 0;
            }

            @Override
            public List<Map<String, Object>> getContent() {
                return null;
            }

            @Override
            public boolean hasContent() {
                return false;
            }

            @Override
            public Sort getSort() {
                return null;
            }

            @Override
            public boolean isFirst() {
                return false;
            }

            @Override
            public boolean isLast() {
                return false;
            }

            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public boolean hasPrevious() {
                return false;
            }

            @Override
            public Pageable nextPageable() {
                return null;
            }

            @Override
            public Pageable previousPageable() {
                return null;
            }

            @Override
            public Iterator<Map<String, Object>> iterator() {
                return null;
            }
        };
        return mapPage;
    }

    @Override
    public OrderType createOrderType(String typeName, Integer typeSeq,
        String errandOrderTypeDetaileds, String typepicture, String otherServices, String tips,
        String allowTips) {
        OrderType orderType = new OrderType();
        return orderType;
    }

    @Override
    public Map<String, Object> getNewPrice(Long areaId, Double distance, Integer time) {
        Map<String, Object> map = new HashMap<String, Object>();
        return map;
    }

    @Override
    public Map<String, Object> getNewWeightPrice(Long areaWeightId,
        double weight) {
        Map<String, Object> map = new HashMap<String, Object>();
        return map;
    }

    /**
     * 修改跑腿类型
     */
    @Override
    public int updateOrderType(Long id, String typeName, Integer typeSeq,
        String errandOrderTypeDetaileds, String typepicture,
        String otherServices, String tips, String allowTips) {
        return 0;
    }

    @Override
    public Map<String, Object> deleteOrderType(Long typeId) {
        Map<String, Object> map = new HashMap<String, Object>();
        return map;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result<OrderUp> confirmTask(OrderUp order, String xml, String memo) {
        Result<OrderUp> result = new Result<OrderUp>();
        return result;

    }

    @Transactional(rollbackFor = Exception.class)
    public Result<OrderUp> completeTaskNewV3(OrderUp order, Passenger passenger, Driver driver,
        String completeType, String payType, BigDecimal hasPayed) {

        Result<OrderUp> result = new Result<OrderUp>();
        return result;
    }

    /**
     * 创建交易记录
     */
    @Override
    public Result<PayRecordOrder> createPayRecordOrder(PayRecordOrder payRecordOrder) {
        Result<PayRecordOrder> result = new Result<PayRecordOrder>();
        return result;
    }

    /**
     * 查询交易记录
     */
    @Override
    public PayRecordOrder findOnePayRecordOrder(Long id) {
        PayRecordOrder payRecordOrder = new PayRecordOrder();
        return payRecordOrder;
    }

    /**
     * 修改交易记录
     */
    @Override
    public Result<PayRecordOrder> payRecordOrderTreatment(PayRecordOrder payRecordOrder) {

        Result<PayRecordOrder> result = new Result<PayRecordOrder>();
        return result;
    }

    @Override
    public List<Map<String, Object>> queryByEmployId(Long employId, String status, Double latitude,
        Double longitude) {
        List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
        return listMap;
    }

    @Override
    public List<OrderUp> listByEmployId(Long employId, String status, Double latitude,
        Double longitude) {
//        StringBuilder builder = new StringBuilder();
//        builder.append(errandApi.getErrandBaseURL()).append(ErrandUpApi.QUERY_ORDER).append("?appKey={appKey}");
//        Map<String, String> kv = new HashMap<String, String>();
//        if (employId != null && employId != 0) {
//            kv.put("employId", String.valueOf(employId));
//            builder.append("&employId={employId}");
//        }
//        if (status != null) {
//            kv.put("status", status);
//            builder.append("&status={status}");
//        }
//        String result = errandApi.get(builder.toString(), kv, settingUtils.get());
//
//        List<OrderUp> orderList = null;
//
//        if (null != result) {
//            JSONObject jo = new JSONObject(result);
//            Integer code = jo.getInt("code");
//            if (code == 0) {
//                JSONObject data = jo.getJSONObject("data");
//                JSONArray ja = data.getJSONArray("rows");
//                Gson gson = new GsonBuilder().setDateFormat(com.ybkj.daijia.constant.DateConstant.DATE_TIME_FORMATE).create();
//                orderList = gson.fromJson(ja.toString(), new TypeToken<List<OrderUp>>() {
//                }.getType());
//
//                if (!CollectionUtils.isEmpty(orderList)) {
//
//                    for (int i = 0; i < orderList.size(); i++) {
//                        OrderUp order = orderList.get(i);
//                        if (order.getStartLat() != null && order.getStartLng() != null && latitude != null && longitude != null) {
//
//                            Double length = Distance.doubleVal(order.getStartLat(), order.getStartLng(), latitude, longitude);
//                            if (length > 0 && length <= 1) {
//                                BigDecimal decimal = new BigDecimal(1000 * length);
//                                BigDecimal abs = decimal.abs(new MathContext(3));
//                                String str = abs.intValue() + "米";
//                                order.setDistanceStr(str);
//                                order.setDistance(new BigDecimal(length).abs(new MathContext(3)).doubleValue());
//                            } else if (length > 1) {
//                                BigDecimal decimal = new BigDecimal(length);
//                                if (length <= 10) {
//                                    BigDecimal abs = decimal.abs(new MathContext(2));
//                                    String str = abs + "公里";
//                                    order.setDistanceStr(str);
//                                    order.setDistance(new BigDecimal(length).abs(new MathContext(2)).doubleValue());
//                                } else if (length > 10 && length < 100) {
//                                    BigDecimal abs = decimal.abs(new MathContext(3));
//                                    String str = abs + "公里";
//                                    order.setDistanceStr(str);
//                                    order.setDistance(new BigDecimal(length).abs(new MathContext(3)).doubleValue());
//                                } else if (length > 100 && length <= 1000) {
//                                    BigDecimal abs = decimal.abs(new MathContext(4));
//                                    String str = abs + "公里";
//                                    order.setDistanceStr(str);
//                                    order.setDistance(new BigDecimal(length).abs(new MathContext(4)).doubleValue());
//                                } else {
//                                    BigDecimal abs = decimal.abs(new MathContext(5));
//                                    String str = abs + "公里";
//                                    order.setDistanceStr(str);
//                                    order.setDistance(new BigDecimal(length).abs(new MathContext(5)).doubleValue());
//                                }
//                            }
//                        }
//                        Area area = new Area();
//                        if (order.getAreaId() != null) {
//                            area = areaMapper.selectByPrimaryKeyWithCharge(order.getAreaId());
//                        }
//                        order.setArea(area);
//                        //添加重量收费标准
//                        AreaWeight areaWeight = new AreaWeight();
//                        if (order.getAreaWeightId() != null) {
//                            areaWeight = areaMapper.selectWeightByPrimaryKey(order.getAreaWeightId());
//                        }
//                        order.setAreaWeight(areaWeight);
//                        order.setErrandValuationMethod(false);
//                        ErrandTypeCompany company = new ErrandTypeCompany();
//                        Page<ErrandTypeCompany> companyList = this.queryErrandTypeCompany(order.getOrderTypeId(), order.getCompanyName());
//                        if (null != companyList.getContent() && companyList.getContent().size() > 0) {
//                            company = companyList.getContent().get(0);
//                        }
//                        if (null != company) {
//                            if (null != company.getPayType() && company.getPayType().equals("1")) {
//                                order.setErrandValuationMethod(true);
//                            }
//                        }
//                    }
//                }
//            }
//        }
        List<OrderUp> orderList = new LinkedList<>();
        return orderList;
    }

    @Override
    public void acceptInfoFee(Driver driver, OrderUp order) {
    }

//	}

    @Override
    public OrderOrbit findOrbitByOrderId(Long id) {
        OrderOrbit orderOrbit = new OrderOrbit();
        return orderOrbit;
    }

    /**
     * 查询调度新单
     */
    @Override
    public List<OrderUp> listNewOrders() {
        List<OrderUp> list = new LinkedList<>();

        return list;
    }


    @Override
    public List<OrderUp> findActivedOrdersByDriver(Long employId) {
        List<OrderUp> list = new LinkedList<>();
        return list;
    }

    @Override
    public Map<String, Object> findRate(Long driverid, Integer page,
        Integer limit) {
        Map<String, Object> map = new HashMap<>();
        return map;
    }

    @Override
    public Rate findRateOne(Long id) {
        Rate r = new Rate();
        return r;
    }

    @Override
    public void deleteRateOne(Long id) {

    }

    @Override
    public long countFinishedByPassengerAndFinishTime(Long passengerId, String orderFromSources,
        Date startDate, Date endDate) {

        return 0L;
    }

    @Override
    public Result<OrderUp> updateRealMoney(OrderUp order, BigDecimal couponMoney,
        BigDecimal cashMoney, BigDecimal signMoney,
        BigDecimal balanceMoney, BigDecimal alipayMoney, BigDecimal weixinMoney,
        BigDecimal driverMoney,
        BigDecimal memberMoney, String content) {
        Result<OrderUp> result = new Result<OrderUp>();
        return result;
    }

    @Override
    public List<OrderUp> findOrderFinishedBycompanyId(Long companyId, Date start, Date end) {

//        StringBuilder builder = new StringBuilder();
//        builder.append(errandApi.getErrandBaseURL()).append(ErrandUpApi.FINDBYPARAMS_V2).append("?appKey={appKey}");
//        Map<String, String> kv = new HashMap<String, String>();
//        if (start != null) {
//            builder.append("&startFinishTime={startFinishTime}");
//            kv.put("startFinishTime", start.getTime() + "");
//        }
//        if (end != null) {
//            builder.append("&endFinishTime={endFinishTime}");
//            kv.put("endFinishTime", end.getTime() + "");
//        }
//        builder.append("&allstatus={allstatus}");
//        kv.put("allstatus", String.valueOf(4));
//        if (companyId != null) {
//            builder.append("&companyId={companyId}");
//            kv.put("companyId", String.valueOf(companyId));
//        }
//        String result = errandApi.get(builder.toString(), kv, settingUtils.get());
//        List<OrderUp> orderFromSourceVos = null;
//        if (null != result) {
//            JSONObject jo = new JSONObject(result);
//            Integer code = jo.getInt("code");
//            if (code == 0) {
//                JSONObject jobj = jo.getJSONObject("data");
//                JSONArray data = jobj.getJSONArray("rows");
//                Gson gson = new GsonBuilder().setDateFormat(com.ybkj.daijia.constant.DateConstant.DATE_TIME_FORMATE).create();
//                orderFromSourceVos = gson.fromJson(data.toString(), new TypeToken<List<OrderUp>>() {
//                }.getType());
//            }
//        }
        List<OrderUp> orderFromSourceVos = new LinkedList<>();

        return orderFromSourceVos;
    }

    @Override
    public long countNotPayByPassenger(Long passengerId) {

//        Long notPayAmounts = 0L;
//
//        try {
//            StringBuilder builder = new StringBuilder();
//            builder.append(errandApi.getErrandBaseURL()).append(ErrandUpApi.COUNT_NOTPAY_BY_PASSENGER).append("?appKey={appKey}");
//            Map<String, String> kv = new HashMap<String, String>();
//            builder.append("&passengerId={passengerId}");
//            kv.put("passengerId", String.valueOf(passengerId));
//            String result = errandApi.get(builder.toString(), kv,
//                    settingUtils.get());
//            if (null != result) {
//                JSONObject jo = new JSONObject(result);
//                Integer code = jo.getInt("code");
//                if (code == 0) {
//                    notPayAmounts = jo.getLong("data");
//                }
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//        return notPayAmounts;
        return 0L;
    }

    @Override
    public Page<OrderUp> findByDriverAndFinishTime(Long employId, Date start,
        Date end, Integer page, Integer limit) {
        Page<OrderUp> orderUps = new Page<OrderUp>() {
            @Override
            public int getTotalPages() {
                return 0;
            }

            @Override
            public long getTotalElements() {
                return 0;
            }

            @Override
            public int getNumber() {
                return 0;
            }

            @Override
            public int getSize() {
                return 0;
            }

            @Override
            public int getNumberOfElements() {
                return 0;
            }

            @Override
            public List<OrderUp> getContent() {
                return null;
            }

            @Override
            public boolean hasContent() {
                return false;
            }

            @Override
            public Sort getSort() {
                return null;
            }

            @Override
            public boolean isFirst() {
                return false;
            }

            @Override
            public boolean isLast() {
                return false;
            }

            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public boolean hasPrevious() {
                return false;
            }

            @Override
            public Pageable nextPageable() {
                return null;
            }

            @Override
            public Pageable previousPageable() {
                return null;
            }

            @Override
            public Iterator<OrderUp> iterator() {
                return null;
            }
        };
        return orderUps;
    }

    @Override
    public List<OrderUp> findReward(Long driverId, BigDecimal lowestMoney, Date start, Date end) {

        List<OrderUp> list = new ArrayList<OrderUp>();
        return list;
    }

    @Override
    public long countActiveByPassenger(Long passengerId) {
        return 0L;
    }

    @Override
    public long countTodayOrderByPassenger(Long passengerId) {
        return 0L;
    }

    @Override
    public List<OrderType> findByTypeName(String typeName) {

        List<OrderType> list = new ArrayList<OrderType>();
        return list;
    }

    @Override
    public PageVo<DriverOrderDetailVo> driverOrderDetailCount(Long driverId, Date start, Date end) {
        PageVo<DriverOrderDetailVo> page = new PageVo<>();

        return page;
    }

    @Override
    public OrderType findByTypeId(Long id) {
        OrderType orderType = new OrderType();
        return orderType;
    }

    @Override
    public List<OrderType> queryTypeV4(Long companyId) {
        List<OrderType> orderTypes = new ArrayList<OrderType>();
        return orderTypes;
    }

    @Override
    public void updateOrderPayed(Long id, String ifPayed, Double payed, String payTypeDetails) {
    }

    @Override
    public Result<OrderUp> updatePayStatus(Long id, PayTypeDetails prePayType,
        BigDecimal shouldPayMoney, BigDecimal couponMoney) {

        Result<OrderUp> result = new Result<>();
        return result;
    }

    @Override
    public ErrandOrderTypeOtherServices getOtherServiceById(String id) {

        ErrandOrderTypeOtherServices errandOrderTypeOtherServices = new ErrandOrderTypeOtherServices();
        return errandOrderTypeOtherServices;
    }

    @Override
    public ErrandOrderTypeTips getTipsById(String id) {

        return new ErrandOrderTypeTips();
    }

    @Override
    public OrderUp tempToForever(Long id, PayTypeDetails prePayType, Coupon coupon) {
        OrderUp orderUp = new OrderUp();
        return orderUp;
    }

    @Override
    public int getAllTypeCount() {
        return 0;
    }

    @Override
    public Map<String, Object> openCompany(Long typeId, Long companyId,
        String companyName, Long mileAreaId, Long weightAreaId,
        String ifPrepay, String payType, String mileAreaName, String weightAreaName) {
        Map<String, Object> map = new HashMap<String, Object>();

        return map;
    }

    @Override
    public Page<ErrandTypeCompany> queryErrandTypeCompany(Long typeId,
        String companyName) {
        Page<ErrandTypeCompany> page = new Page<ErrandTypeCompany>() {
            @Override
            public int getTotalPages() {
                return 0;
            }

            @Override
            public long getTotalElements() {
                return 0;
            }

            @Override
            public int getNumber() {
                return 0;
            }

            @Override
            public int getSize() {
                return 0;
            }

            @Override
            public int getNumberOfElements() {
                return 0;
            }

            @Override
            public List<ErrandTypeCompany> getContent() {
                return null;
            }

            @Override
            public boolean hasContent() {
                return false;
            }

            @Override
            public Sort getSort() {
                return null;
            }

            @Override
            public boolean isFirst() {
                return false;
            }

            @Override
            public boolean isLast() {
                return false;
            }

            @Override
            public boolean hasNext() {
                return false;
            }

            @Override
            public boolean hasPrevious() {
                return false;
            }

            @Override
            public Pageable nextPageable() {
                return null;
            }

            @Override
            public Pageable previousPageable() {
                return null;
            }

            @Override
            public Iterator<ErrandTypeCompany> iterator() {
                return null;
            }
        };
        return page;
    }

    @Override
    public Map<String, Object> updateErrandTypeCompany(Long typeId,
        Long companyId, String companyName, Long mileAreaId,
        Long weightAreaId, String ifPrepay, String payType,
        String mileAreaName, String weightAreaName) {
        Map<String, Object> map = new HashMap<String, Object>();
        return map;
    }

    @Override
    public Map<String, Object> deleteTypeCompany(Long typeCompanyId) {
        Map<String, Object> map = new HashMap<String, Object>();
        return map;
    }

    @Override
    public void backMoney(Long orderId) {
    }
}
